/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#include "Game/Game/ItemEnchantmentMgr.h"


std::uint32_t getItemEnchantMod(std::uint32_t entry)
{
    if (!entry) { return 0; }

    //EnchantmentStore::const_iterator tab = RandomItemEnch.find(entry);
    //
    //if (tab == RandomItemEnch.end())
    //{
    //    sLog.outErrorDb("Item RandomProperty id #%u used in `item_template` but it doesn't have records in `item_enchantment_template` table.", entry);
    //    return 0;
    //}
    //
    //double dRoll = rand_chance();
    //float fCount = 0;
    //
    //for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
    //{
    //    fCount += ench_iter->chance;
    //
    //    if (fCount > dRoll) { return ench_iter->ench; }
    //}
    //
    //// we could get here only if sum of all enchantment chances is lower than 100%
    //dRoll = (irand(0, (int)floor(fCount * 100) + 1)) / 100;
    //fCount = 0;
    //
    //for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
    //{
    //    fCount += ench_iter->chance;
    //
    //    if (fCount > dRoll) { return ench_iter->ench; }
    //}

    return 0;
}